package com.wgc.vip.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wgc.entity.PageResult;
import com.wgc.entity.Result;
import com.wgc.vip.domain.Funds;
import com.wgc.vip.service.FundsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * 会员余额
 */
@RestController
@RequestMapping("/funds")
public class FundsController {
    @Autowired
    private FundsService fundsService;
    /**
     *查看全部
     *  */
    @RequestMapping("/getAll")
    public Result<List<Funds>> getAll(){
        return new Result("查询成功",fundsService.getAll());
    }


    /**
     * 分页搜索实现
     */
    @GetMapping(value = "/pageList" )
    public Result pageList(@RequestParam(defaultValue = "1")  Integer page, @RequestParam(defaultValue = "10") Integer size) {
        Page<Funds> ePage = fundsService.pageAll(page, size);
        PageResult<Funds> pageResult = new PageResult<>(ePage.getTotal(), ePage.getRecords());
        return new Result<>("查询成功", pageResult);
    }
    /**
     * 分页条件搜索
     */
    @GetMapping(value = "/pageList" )
    public Result pageList(@RequestBody Funds e, @RequestParam(defaultValue = "1")  Integer page, @RequestParam(defaultValue = "10") Integer size) {
        Page<Funds> ePage = fundsService.pageList(e, page, size);
        PageResult<Funds> pageResult = new PageResult<>(ePage.getTotal(), ePage.getRecords());
        return new Result<>("查询成功", pageResult);
    }
    /**
     * 条件查询
     */
    @GetMapping("/selectList")
    public Result<List<Funds>> getByName(@RequestBody Funds funds){
        return new Result("查询成功",fundsService.selectList(funds));
    }
}
